Add some more GtkWindow tests
authorMatthias Clasen <mclasen@redhat.com>
Sat, 27 Apr 2013 22:01:19 +0000 (18:01 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Sat, 4 May 2013 20:16:11 +0000 (16:16 -0400)
These tests check that a toplevel window ends up with the expected
size after setting default sizes or resizing. It currently passes
on X, but fails with client-side decorations under X and Wayland.

gtk/tests/window.c

index 1aecdfc790378920cdc51981956a947a91f07fdf..b24947112af6c1064ae8ff5cc58ed26b4e776b0c 100644 (file)
@@ -27,16 +27,56 @@ test_default_size (void)
   gtk_window_get_default_size (GTK_WINDOW (window), &w, &h);
   g_assert (w == 300 && h == 300);
 
+  gtk_window_get_size (GTK_WINDOW (window), &w, &h);
+  g_assert (w == 300 && h == 300);
+
   gtk_widget_show_all (window);
 
   g_timeout_add (1000, stop_main, NULL);
   gtk_main ();
 
+  gtk_window_get_size (GTK_WINDOW (window), &w, &h);
+  g_assert (w == 300 && h == 300);
+
   g_assert (gtk_widget_get_allocated_width (window) == 300);
   g_assert (gtk_widget_get_allocated_height (window) == 300);
 
   g_assert (gtk_widget_get_allocated_width (box) == 300);
   g_assert (gtk_widget_get_allocated_height (box) == 300);
+
+  gtk_widget_destroy (window);
+}
+
+static void
+test_resize (void)
+{
+  GtkWidget *window;
+  GtkWidget *box;
+  gint w, h;
+
+  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+  box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
+  gtk_container_add (GTK_CONTAINER (window), box);
+
+  gtk_window_resize (GTK_WINDOW (window), 400, 200);
+
+  gtk_widget_show_all (window);
+
+  g_timeout_add (1000, stop_main, NULL);
+  gtk_main ();
+
+  gtk_window_get_size (GTK_WINDOW (window), &w, &h);
+  g_assert (w == 400 && h == 200);
+
+  gtk_window_resize (GTK_WINDOW (window), 200, 400);
+
+  g_timeout_add (1000, stop_main, NULL);
+  gtk_main ();
+
+  gtk_window_get_size (GTK_WINDOW (window), &w, &h);
+  g_assert (w == 200 && h == 400);
+
+  gtk_widget_destroy (window);
 }
 
 int
@@ -45,6 +85,7 @@ main (int argc, char *argv[])
   gtk_test_init (&argc, &argv);
 
   g_test_add_func ("/window/default-size", test_default_size);
+  g_test_add_func ("/window/resize", test_resize);
 
   return g_test_run ();
 }